<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>系统配置</title>
    <!--{include file="comm/icheck.tpl"}-->
</head>
<body>

<div class="ebsig_container">
    <div class="comm_content">
        <!--{if isset($group_array)}-->
            <ul class="nav nav-tabs">
                <!--{foreach from=$group_array item=v}-->
                    <!--{if $v.config_group_id== $group_id}-->
                        <li class="active"><a href="javascript: void(0);"><!--{$v.config_group_name}--></a></li>
                    <!--{else}-->
                        <li><a href="/quanliadmin/app/system/config.pscript?operFlg=1&group_id=<!--{$v.config_group_id}-->"><!--{$v.config_group_name}--></a></li>
                    <!--{/if}-->
                <!--{/foreach}-->
            </ul>
        <!--{/if}-->
        <br>
        <!--{if isset($config_array)}-->
            <form class="form-horizontal" id="config_form" onsubmit="return false;" role="form">
                <!--{foreach from=$config_array item=conf}-->
                    <!--{if $conf.config_type == 1 || $conf.config_type == 2 || $conf.config_type == 3 || $conf.config_type == 4}-->

                        <div class="form-group">
                            <label for="<!--{$conf.config_key}-->" class="col-sm-2 control-label"><span class="red">*</span> <!--{$conf.config_title}-->：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" value="<!--{$conf.config_value}-->" id="<!--{$conf.config_key}-->" name="<!--{$conf.config_key}-->" config_type="<!--{$conf.config_type}-->" placeholder="请输入<!--{$conf.config_title}-->" style="width: 300px;">
                                <!--{if $conf.config_type == 3}-->
                                    <span class="help-block">单位为小时</span>
                                <!--{elseif $conf.config_type == 4}-->
                                    <span class="help-block">单位为秒</span>
                                <!--{/if}-->
                            </div>
                        </div>

                    <!--{elseif $conf.config_type == 6}-->

                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="red">*</span> <!--{$conf.config_title}-->：</label>
                            <div class="col-sm-10">
                                <!--{if $conf.config_value == 1}-->
                                    <div class="fl" style="margin-right: 10px;">
                                        <input type="radio" class="square-radio" id="<!--{$conf.config_key}-->-square-radio-1" name="<!--{$conf.config_key}-->" config_type="<!--{$conf.config_type}-->" value="1" checked>
                                        <label for="<!--{$conf.config_key}-->-square-radio-1">是</label>
                                    </div>
                                    <div class="fl">
                                        <input type="radio" class="square-radio" id="<!--{$conf.config_key}-->-square-radio-0" name="<!--{$conf.config_key}-->" config_type="<!--{$conf.config_type}-->" value="0">
                                        <label for="<!--{$conf.config_key}-->-square-radio-0">否</label>
                                    </div>
                                <!--{else}-->
                                    <div class="fl" style="margin-right: 10px;">
                                        <input type="radio" class="square-radio" id="<!--{$conf.config_key}-->-square-radio-1" name="<!--{$conf.config_key}-->" config_type="<!--{$conf.config_type}-->" value="1">
                                        <label for="<!--{$conf.config_key}-->-square-radio-1">是</label>
                                    </div>
                                    <div class="fl">
                                        <input type="radio" class="square-radio" id="<!--{$conf.config_key}-->-square-radio-0" name="<!--{$conf.config_key}-->" config_type="<!--{$conf.config_type}-->" value="0" checked>
                                        <label for="<!--{$conf.config_key}-->-square-radio-0">否</label>
                                    </div>
                                <!--{/if}-->
                            </div>
                        </div>

                    <!--{elseif $conf.config_type == 9}-->

                        <div class="form-group">
                            <label for="<!--{$conf.config_key}-->" class="col-sm-2 control-label"><span class="red">*</span> <!--{$conf.config_title}-->：</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" value="<!--{$conf.config_value}-->" id="<!--{$conf.config_key}-->" name="<!--{$conf.config_key}-->" config_type="<!--{$conf.config_type}-->" placeholder="<!--{$conf.config_title}-->" style="width: 300px;">
                            </div>
                        </div>

                    <!--{/if}-->

                <!--{/foreach}-->

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" class="btn btn-primary" id="config_save">保存</button>
                    </div>
                </div>

            </form>
        <!--{else}-->
            <div class="alert alert-warning">暂无配置信息</div>
        <!--{/if}-->

    </div>


</div>

<script type="text/javascript">

    $(window).ready(function() {

        $('.square-radio').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' // optional
        });

        $('#config_save').on('click', function() {
            config.check();
        });

    });

    var config = {

        group_id: '<!--{$group_id}-->',

        check: function() {

            this.dt = E.getFormValues('config_form');
            var error_msg = '';
            $.each(this.dt, function(k, v) {
                if (E.isEmpty(v)) {
                    var name = $('input[name=' + k + ']').attr('placeholder');
                    var config_type = $('input[name=' + k + ']').attr('config_type');
                    if (config_type == 9) {
                        return false;
                    }
                    error_msg += name + '不能为空';
                }
            });
            if (error_msg != '') {
                E.alert(error_msg);
            } else {
                E.confirm('您确认要修改配置吗？', 'config.edit');
            }

        },

        edit: function() {
            E.loadding.open("正在修改配置，请稍候...");
            E.ajax_post({
                url: '/invokingAjax-backend/system/config.ajax?operFlg=1',
                data: {
                    group_id: this.group_id,
                    params: this.dt
                },
                call: 'config.result'
            });
        },

        result: function( o ) {
            E.loadding.close();
            if (o.code == 200) {
                E.alert(o.message, 2);
            } else {
                E.alert(o.message);
            }
        }

    };

</script>

</body>
</html>